package users

// 表名也是cache的tag
var TableName = "users"

// 每个商家一个用户表
type Users struct {
	Id int64

	Tid int64 `xorm:"integer notnull 'tid'"`
	Pid int64 `xorm:"integer notnull 'pid'"`

	Username    string `xorm:"varchar(64) notnull unique 'username'"`
	Nickname    string `xorm:"varchar(64) notnull unique 'nickname'"`
	Password    string `xorm:"varchar(64) notnull 'password'"`
	SecPassword string `xorm:"varchar(64) notnull 'sec_password'"`

	Lang string `xorm:"varchar(32) notnull 'lang'"`

	UserType int `xorm:"tinyint notnull default(1) 'user_type'"`
	IsTester int `xorm:"tinyint notnull default(1) 'is_tester'"`
	IsEditor int `xorm:"tinyint notnull default(1) 'is_editor'"`

	ScoreGroup int64 `xorm:"integer notnull 'score_group'"`

	Avatar string `xorm:"varchar(64) notnull 'avatar'"`
	Phone  string `xorm:"char(11) null default('') 'phone'"`
	LinkId string `xorm:"varchar(64) null default('') 'link_id'"`

	VipLevel     int `xorm:"tinyint notnull default(1) 'vip_level'"`
	UserLevel    int `xorm:"tinyint notnull default(1) 'user_level'"`
	FinanceLevel int `xorm:"tinyint notnull default(1) 'finance_level'"`

	LockType int `xorm:"tinyint notnull default(1) 'lock_type'"`

	RegisterTime  int64  `xorm:"integer notnull 'register_time'"`
	RegisterIp    string `xorm:"char(15) notnull 'register_ip'"`
	LastLoginTime int64  `xorm:"integer null 'last_login_time'"`
	LastLoginIp   string `xorm:"char(15) null 'last_login_ip'"`

	// 注册属性
	RegisterDevice int `xorm:"tinyint notnull default(1) 'register_device'"`
	RegisterType   int `xorm:"tinyint notnull default(1) 'register_type'"`

	AddAdminId int64 `xorm:"integer notnull default(0) 'add_admin_id'"`

	// 推广数据
	ChildrenDirectCount int `xorm:"integer notnull default(0) 'direct_child_count'"`
	ChildrenCount       int `xorm:"integer notnull default(0) 'child_count'"`

	// 登录次数
	LoginTimes int `xorm:"integer notnull default(0) 'login_times'"`

	State int `xorm:"tinyint notnull 'state'"`

	LockTypeName string `xorm:"-"`
	UserTypeName string `xorm:"-"`
}
